package com.itbaizhan.controller;

import com.itbaizhan.pojo.ItemES;
import com.itbaizhan.result.BaseResult;
import com.itbaizhan.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author spf
 * @date 2024/3/6
 * @time 11:12
 */
@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @GetMapping("/findPage")
    public BaseResult<List<ItemES>> findPage(@RequestParam("city") String city,
                                                     @RequestParam("content") String content,
                                                     @RequestParam("page") int page,
                                                     @RequestParam(value = "rows", defaultValue = "4") int rows){
        List<ItemES> search = searchService.search(city, content, page, rows);
        return BaseResult.ok(search);
    }

}
